package com.qdlc.p2p.dal.dao.impl;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Service;

import com.qdlc.p2p.dal.common.dao.jpa.BaseDaoImpl;
import com.qdlc.p2p.dal.dao.EnjoyUploadDao;
import com.qdlc.p2p.dal.dto.EnjoyUpload;

/**
 * Created by D on 2016/1/20.
 */
@Service("enjoyUploadDao")
public class EnjoyUploadDaoImpl extends BaseDaoImpl<EnjoyUpload> implements EnjoyUploadDao {

    @SuppressWarnings("unchecked")
    @Override
    public List<EnjoyUpload> findPicByGoodsId(long id) {
        Query query = em.createQuery("from EnjoyUpload where goodsId=?")
                .setParameter(1, id);
        return query.getResultList();
    }

    @Override
    public List findPicByIdAndType(long id, int type) {
        Query query = em.createQuery("select picPath from EnjoyUpload where goodsId=?1 and type=?2")
                .setParameter(1, id).setParameter(2,type);
        return query.getResultList();
    }
}
